package com.hgf.helper.mybatisplusdemo.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hgf.helper.mybatisplus.PageParam;
import com.hgf.helper.mybatisplusdemo.db.entity.Student;
import com.hgf.helper.mybatisplusdemo.db.service.StudentServiceImpl;
import com.hgf.helper.mybatisplusdemo.pojo.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("student")
public class StudentController {

    @Autowired
    StudentServiceImpl studentService;

    /**
     * 连表查询多条记录
     */
    @GetMapping("joinListTest")
    public List<Student> joinListTest() {
        return studentService.joinListTest();
    }

    /**
     * 连表查询单个记录
     */
    @GetMapping("joinOneTest")
    public Student joinOneTest() {
        return studentService.joinOneTest();
    }

    /**
     * 连表查询单个记录，返回其他类型
     */
    @GetMapping("joinOneOtherClassTest")
    public ResultVo joinOneOtherClassTest() {
        return studentService.joinOneOtherClassTest();
    }

    /**
     * 连表查询单个记录，返回其他类型
     */
    @GetMapping("joinListOtherClassTest")
    public List<ResultVo> joinListOtherClassTest() {
        return studentService.joinListOtherClassTest();
    }

    /**
     * 分页查询测试
     */
    @GetMapping("joinPageTest")
    public Page<Student> joinPageTest(PageParam<Student> pageParam){
        return studentService.joinPageTest(pageParam);
    }

    /**
     * 分页查询测试
     */
    @GetMapping("joinTargetPageTest")
    public Page<ResultVo> joinTargetPageTest(PageParam<Student> pageParam){
        return studentService.joinTargetPageTest(pageParam);
    }

    /**
     * 原始sql查询
     */
    @GetMapping("getOneByOriginSql")
    public Student getOneByOriginSql(){
        return studentService.getOneByOriginSql();
    }

    /**
     * 原始sql修改
     */
    @GetMapping("UpdateOneByOriginSql")
    public boolean UpdateOneByOriginSql(){
        return studentService.updateOneByOriginSql();
    }

    /**
     * updateCase 测试
     */
    @GetMapping("updateCase")
    public boolean updateCase(){
        return studentService.updateCase();
    }

    /**
     * 特殊条件封装测试
     */
    @GetMapping("getById")
    public Student getById(){
        return studentService.getById();
    }

    /**
     * xml查询测试
     */
    @GetMapping("joinQueryXml")
    public Object joinQueryXml(){
        return studentService.joinQueryXml();
    }
}
